﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class View_categories : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadData();
        }
    }
    public void loadData()
    {
        Article_BU articlebus = new Article_BU();
        DataTable dt = new DataTable();
        if (Request.QueryString["path"] != null && Request.QueryString["path"] != "")
        {
            int category_id = Convert.ToInt32(Request.QueryString["path"]);
            dt=articlebus.getArticleByCategoryID(loadLanguage(),category_id, 100);
        }
               
        
        foreach (DataRow r in dt.Rows)
        {
            r["image"] = "images/upload/" + r["image"];
               
        }
        
        articles.DataSource = dt;
        articles.DataBind();

    }
    public int loadLanguage()
    {
        try
        {
            HttpCookie cookie = Request.Cookies["language"];
            return Convert.ToInt32(cookie["language"]);
        }
        catch (Exception)
        {
            return 1;
        }
    }
}